package com.my.springbootemail.web;

import com.my.common.result.R;
import com.my.springbootemail.bean.Mail;
import com.my.springbootemail.service.MailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @Author marshal
 * @Date 2021-06-12 12:48 PM
 */
@RestController
@RequestMapping("/mail")
@Api(tags = "mail", value = "邮件管理")
public class MailController {

    @Autowired
    private MailService mailService;

    @PatchMapping("/simple")
    @ApiOperation(value = "发送简单邮件")
    public R<Object> sentSimpleMail(@RequestBody Mail mail) {
        if (Objects.isNull(mail)) {
            return R.failed("参数不能为空！");
        }
        mailService.sendSimpleMail(mail);
        return R.success();
    }

}
